<template>
  <section>
    <el-tabs v-model="pageName" v-if="currStore">
      <el-tab-pane label="商品分类" name="first">
        <goods-type v-if="pageName === 'first'"></goods-type>
      </el-tab-pane>
      <el-tab-pane label="商品管理" name="second">
        <mall-goods-list v-if="pageName === 'second'"></mall-goods-list>
      </el-tab-pane>
    </el-tabs>
    <div v-else style="color: red;font-weight: bold;font-size: 20px;text-align: center;margin-top: 30%">
      当前部门未建立商铺，请确认！
    </div>
  </section>
</template>

<script>
  import goodsType from '../mallGoodsType/goodsType'
  import mallGoodsList from './mallGoodsList'
  import errHandler from '@/assets/errHandler.js'
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  export default {
    name: "index",
    components: {goodsType,mallGoodsList},
    data() {
      return {
        pageName:'first',
        currStore:null
      }
    },
    created() {
      //先看下有没有store
      this.getStore()
    },
    mounted() {
    },
    computed: {
      ...mapGetters(['department']),
    },
    watch: {},
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      getStore(){
        this.fetch({name:"getStore",data:{departmentId: this.department.id}})
          .then(res=>{
            console.log('当前店铺-----',res)
            this.currStore=res
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
    }
  }
</script>

<style scoped>

</style>
